/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sdc.event;

import java.util.List;
import sdc.component.type.ComponentType;
import sdc.net.server.comp.ComponentServer;
import sdc.strategyfactory.Strategy;

/**
 *
 * @author yokoe
 */
public class ComponentAllocationEvent extends Event
{

	private ComponentType componentType;
	private Strategy factory;
	private int duplicateNum;

	public ComponentAllocationEvent(double eventTime, ComponentType componentType, int duplicateNum, Strategy strategyFactory)
	{
		super(eventTime);
		this.componentType = componentType;
		this.duplicateNum = duplicateNum;
		this.factory = strategyFactory;
	}

	@Override
	public void fire()
	{
		List<ComponentServer> componentServers = factory.getStrategyForAllocation().allocateComponents(componentType, duplicateNum);

		EventQueue eventQueue = EventQueue.INSTANCE;

		eventQueue.addEvent(new OverlayConstructEvent(EventHelper.generateNextEventTime(), componentType, componentServers));
	}
}
